package com.ty.day3;

import java.math.BigDecimal;
import java.math.MathContext;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/24 15:21
 */
public class Demo01 {
    public static void main(String[] args) {
        String[] strs={"123","33.3","123","789.3","123.56"};
        Double sum=0.0;
        BigDecimal decimal=new BigDecimal("0");
        for (String s:strs){
            sum+=Double.parseDouble(s);
            decimal= decimal.add(new BigDecimal(s));
        }
        System.out.println(sum);
        System.out.println(decimal);
        BigDecimal d1 = new BigDecimal("10");
        BigDecimal d2 = new BigDecimal("3");
        BigDecimal add = d1.add(d2);
        System.out.println(add);
        BigDecimal multiply = d1.multiply(d2);
        System.out.println(multiply);
        BigDecimal divide = d1.divide(d2, MathContext.DECIMAL32);
        System.out.println(divide);
        BigDecimal subtract = d1.subtract(d2);
        System.out.println(subtract);
    }

}
class Example{
    public static void main(String args[]){
        Example ex=new Example();
        String x=new String("avb");
        change(x);
        System.out.println(x);

    }
    static void change(String str){
        str="test ok";
    }
}
